﻿function agree_onclick()
{
	document.form1.agree.checked==""
	if(document.form1.agree.checked=="")
	{
		document.form1.submitb.disabled=true;
		document.getElementById("submitb").className="tianya_btn_gray";	
	}
	else
	{
		document.form1.submitb.disabled=false;
		document.getElementById("submitb").className="tianya_btn";
	}
}

function CheckPWDFunc(){
	var ResultContent_CheckPWD;
	var CheckPWD_length = document.forms['form1'].userword.value.length;
	//alert(CheckPWD);
	if (CheckPWD_length == 0)
	{
		document.getElementById("userword").style.backgroundColor = "";
		document.getElementById("userword").style.color = "";	
		ResultContent_CheckPWD='';
		document.getElementById("CheckPWDResult").innerHTML = ResultContent_CheckPWD;
		return (false);
	}
	if (CheckPWD_length >0 && CheckPWD_length < 6)
	{
		document.getElementById("userword").style.backgroundColor = "#FFCCCC";
		document.getElementById("userword").style.color = "#000000";
		ResultContent_CheckPWD='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">用户密码至少6位</FONT>';
		document.getElementById("CheckPWDResult").innerHTML = ResultContent_CheckPWD;
		//document.form1.userword.focus();
		return (false);
	}
	else if (CheckPWD_length > 16)
	{
		document.getElementById("userword").style.backgroundColor = "#FFCCCC";
		document.getElementById("userword").style.color = "#000000";
		ResultContent_CheckPWD='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">用户密码过长</FONT>';
		document.getElementById("CheckPWDResult").innerHTML = ResultContent_CheckPWD;
		//document.form1.userword.focus();
		return (false);
	}
	//20090612 start
	else if (document.forms['form1'].userword.value == document.forms['form1'].login_name.value)
	{
		document.getElementById("userword").style.backgroundColor = "#FFCCCC";
		document.getElementById("userword").style.color = "#000000";
		ResultContent_CheckPWD='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">为了您的帐号安全,请不要使用用户名作为密码</FONT>';
		document.getElementById("CheckPWDResult").innerHTML = ResultContent_CheckPWD;
		//document.form1.userword.focus();
		return (false);
	}
	//20090612 end
	else
	{
		document.getElementById("userword").style.backgroundColor = "";
		document.getElementById("userword").style.color = "";	
		ResultContent_CheckPWD='<img src="res/img/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckPWDResult").innerHTML = ResultContent_CheckPWD;
		return (false);
	}
}

function CheckPWDFunc2(){
	var ResultContent_CheckPWD2;
	var CheckPWD = document.forms['form1'].userword.value;
	var CheckPWD2 = document.forms['form1'].userword2.value;
	//alert(CheckPWD);
	//alert(CheckPWD2);
	if (CheckPWD2 != "" && CheckPWD!= CheckPWD2)
	{
		document.getElementById("userword2").style.backgroundColor = "#FFCCCC";
		document.getElementById("userword2").style.color = "#000000";
		ResultContent_CheckPWD2='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">密码不匹配</FONT>';
		document.getElementById("CheckPWDResult2").innerHTML = ResultContent_CheckPWD2;
		//document.form1.userword.focus();
		return (false);
	}
	else if (CheckPWD2 != "" && CheckPWD == CheckPWD2)
	{
		document.getElementById("userword2").style.backgroundColor = "";
		document.getElementById("userword2").style.color = "";
		ResultContent_CheckPWD2='<img src="res/img/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckPWDResult2").innerHTML = ResultContent_CheckPWD2;
		return (false);
	}
	else
	{
		document.getElementById("userword2").style.backgroundColor = "";
		document.getElementById("userword2").style.color = "";
		ResultContent_CheckPWD2='';
		document.getElementById("CheckPWDResult2").innerHTML = ResultContent_CheckPWD2;
		return (false);
	}
}

function CheckPWDQuestionFunc(){
	var CheckPWDQuestion = document.forms['form1'].password_question.value;
	//alert(CheckPWDQuestion);
	if (CheckPWDQuestion == 12)
	{
		show('tt');
	}
	else
	{
		document.forms['form1'].password_question_special.value = "";
		hide('tt');
	}
	if (CheckPWDQuestion != 0)
	{
		ResultContent_CheckPWD='<img src="res/img/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckPWDQuestionResult").innerHTML = ResultContent_CheckPWD;
		return (false);
	}
	else
	{
		ResultContent_CheckPWD='';
		document.getElementById("CheckPWDQuestionResult").innerHTML = ResultContent_CheckPWD;
		return (false);
	}
}

function CheckPWDQuestionSpecialFunc(){
	var ResultContent_CheckPWDQuestionSpecial;
	var CheckPWDQuestionSpecial = document.forms['form1'].password_question_special.value.length;
	//alert(CheckPWDAnswer);
	if (CheckPWDQuestionSpecial == 0)
	{
		document.getElementById("password_question_special").style.backgroundColor = "";
		document.getElementById("password_question_special").style.color = "";
		ResultContent_CheckPWDQuestionSpecial='';
		document.getElementById("CheckPWDQuestionSpecialResult").innerHTML = ResultContent_CheckPWDQuestionSpecial;
		return (false);
	}
	else if (CheckPWDQuestionSpecial > 0 && (CheckPWDQuestionSpecial < 6 || CheckPWDQuestionSpecial > 30))
	{
		document.getElementById("password_question_special").style.backgroundColor = "#FFCCCC";
		document.getElementById("password_question_special").style.color = "#000000";
		ResultContent_CheckPWDQuestionSpecial='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">自定义问题太短</FONT>';
		document.getElementById("CheckPWDQuestionSpecialResult").innerHTML = ResultContent_CheckPWDQuestionSpecial;
		//document.form1.userword.focus();
		return (false);
	}
	else
	{
		document.getElementById("password_question_special").style.backgroundColor = "";
		document.getElementById("password_question_special").style.color = "";
		ResultContent_CheckPWDQuestionSpecial='<img src="res/img/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckPWDQuestionSpecialResult").innerHTML = ResultContent_CheckPWDQuestionSpecial;
		return (false);
	}
}

function CheckPWDAnswerFunc(){
	var ResultContent_CheckPWDAnswer;
	var CheckPWDAnswer = document.forms['form1'].password_answer.value.length;
	//alert(CheckPWDAnswer);
	if (CheckPWDAnswer == 0)
	{
		document.getElementById("password_answer").style.backgroundColor = "";
		document.getElementById("password_answer").style.color = "";
		ResultContent_CheckPWDAnswer='';
		document.getElementById("CheckPWDAnswerResult").innerHTML = ResultContent_CheckPWDAnswer;
		return (false);
	}
	else if (CheckPWDAnswer > 0 && (CheckPWDAnswer < 6 || CheckPWDAnswer > 30))
	{
		document.getElementById("password_answer").style.backgroundColor = "#FFCCCC";
		document.getElementById("password_answer").style.color = "#000000";
		ResultContent_CheckPWDAnswer='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">问题答案太短</FONT>';
		document.getElementById("CheckPWDAnswerResult").innerHTML = ResultContent_CheckPWDAnswer;
		//document.form1.userword.focus();
		return (false);
	}
	else
	{
		document.getElementById("password_answer").style.backgroundColor = "";
		document.getElementById("password_answer").style.color = "";
		ResultContent_CheckPWDAnswer='<img src="res/img/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckPWDAnswerResult").innerHTML = ResultContent_CheckPWDAnswer;
		return (false);
	}
}

var ResultContent_CheckEMail;
function CheckEMailFunc(){
	var CheckEMail = document.forms['form1'].e_mail.value;
	CheckEMail = CheckEMail.toLowerCase();  //20090511
	if (CheckEMail == "")
	{
		document.getElementById("e_mail").style.backgroundColor = "";
		document.getElementById("e_mail").style.color = "";
		document.getElementById("CheckEMailResult").innerHTML = '';
		return (false);
	}
	else if (CheckEMail != "" && !isEmail(Jtrim(CheckEMail)) )
	{ 
		document.getElementById("e_mail").style.backgroundColor = "#FFCCCC";
		document.getElementById("e_mail").style.color = "#000000";
		document.getElementById("CheckEMailResult").innerHTML = ResultContent_CheckEMail;
		//document.form1.e_mail.focus();
		return (false);
	}
	else
	{
		document.getElementById("e_mail").style.backgroundColor = "";
		document.getElementById("e_mail").style.color = "";
		document.getElementById("CheckEMailResult").innerHTML = '<img src="res/img/icon_ok.gif" width="16" height="16">';
		return (false);
	}
}

function isEmail (s)
{
        // Writen by david, we can delete the before code
        if (s.length > 100)
        {
				ResultContent_CheckEMail='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">Email地址长度不能超过100位!</FONT>';
                return false;
        }

         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int)$"
         var re = new RegExp(regu);
         if (s.search(re) != -1) {
               return true;
         } else {
			   	ResultContent_CheckEMail='<img src="res/img/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">邮箱地址无效</FONT>';
               return false;
         }
} 

function CheckUserNameFunc(){
	var CheckUserName = document.forms['form1'].login_name.value;
	
	if (CheckUserName != ''){
		if (Jtrim(CheckUserName) == "")
			return false;
		else{
			document.getElementById("CheckUserNameResult").innerHTML = '<font color=red>请稍等,检验中...</font>'; 
			checkuser(Jtrim(CheckUserName));
			

		}
	}else{
		document.getElementById("CheckUserNameResult").innerHTML = ''; 
		document.getElementById("login_name").style.backgroundColor = "";
		document.getElementById("login_name").style.color = "";
	}
}
function showGet(){
	showResult_UserName(xmlHttp);
}




function check_choice()
{
	 if (Jtrim(document.form1.login_name.value) == "")
	  {
		window.alert("请填写您的用户名！");
		document.form1.login_name.focus();
		return (false);
	  }

	  if (Jtrim(document.form1.userword.value) == "")
	  {
		window.alert("请填写您的密码！");
		document.form1.userword.focus();
		return (false);
	  }
	  if (Jtrim(document.form1.userword2.value) == "")
	  {
		window.alert("请填写您的确认密码！");
		document.form1.userword2.focus();
		return (false);
	  }
	  if (Jtrim(document.form1.userword.value)!= Jtrim(document.form1.userword2.value))
	  {
		window.alert("您两次填写的密码不一致，请核对！");
		document.form1.userword.focus();
		return (false);
	  }
	  if (document.form1.userword.value.length > 16)
	  {
		window.alert("密码不能超过16位！");
		document.form1.userword.focus();
		return (false);
	  }
	  if (document.form1.userword.value.length < 6)
	  {
		window.alert("密码不能小于6位！");
		document.form1.userword.focus();
		return (false);
	  }		 

	  if (Jtrim(document.form1.e_mail.value) == "")
	  {
		window.alert("请填写EMAIL地址！");
		document.form1.e_mail.focus();
		return (false);
	  }
	  if (!isEmail(Jtrim(document.form1.e_mail.value)) )
	  { document.form1.e_mail.focus();
		return (false);
	  }
		if (document.form1.password_question.value=="")
	  {
		window.alert("请选择一个密码提示问题！");
		document.form1.password_question.focus();
		return (false);
	  }


	/*
	  //旧验证码删除 20080408 开始
	  if (isNaN(document.form1.validate_key.value) == true)
	  {	
		window.alert("请输入正确的验证码！");
		document.form1.validate_key.focus();
		return (false);
	  }
	  //旧验证码删除 20080408 结束
	 */

	document.form1.action="register3_02.asp"
	document.form1.submitb.disabled=true
}

function check_choice_2()
{
	var flag_error="";
	if (Jtrim(document.form1.login_name.value) == "")
	{
		document.getElementById("login_name").style.backgroundColor = "#FFCCCC";
		flag_error="error";
	}
	//alert(document.form1.login_name.value.length);
	if (document.form1.login_name.value.length > 16)
	{
		document.getElementById("login_name").style.backgroundColor = "#FFCCCC";
		flag_error="error";
	}

	if (Jtrim(document.form1.userword.value) == "")
	{
		document.getElementById("userword").style.backgroundColor = "#FFCCCC";
		flag_error="error";
	}
	//if (Jtrim(document.form1.userword2.value) == "")
	//{
	//	document.getElementById("userword2").style.backgroundColor = "#FFCCCC";
	//	flag_error="error";
	//}
	//if (Jtrim(document.form1.userword.value)!= Jtrim(document.form1.userword2.value))
	//{
	//	document.getElementById("userword").style.backgroundColor = "#FFCCCC";
	//	document.getElementById("userword2").style.backgroundColor = "#FFCCCC";
	//	flag_error="error";
	//}
	if (document.form1.userword.value.length > 16)
	{
		document.getElementById("userword").style.backgroundColor = "#FFCCCC";
		flag_error="error";
	}
	if (document.form1.userword.value.length < 6)
	{
		document.getElementById("userword").style.backgroundColor = "#FFCCCC";
		flag_error="error";
	}		 

	//if (Jtrim(document.form1.e_mail.value) == "")
	//{
	//	document.getElementById("e_mail").style.backgroundColor = "#FFCCCC";
	//	flag_error="error";
	//}
	//if (!isEmail(Jtrim(document.form1.e_mail.value)) )
	//{ 
	//	document.getElementById("e_mail").style.backgroundColor = "#FFCCCC";
	//	flag_error="error";
	//}
	//if (document.form1.password_question.value==0)
	//{
	//	document.getElementById("password_question").options[0].style.backgroundColor = "#FFCCCC";
	//	flag_error="error";
	//}
	//if (document.form1.password_answer.value=="")
	//{
	//	document.getElementById("password_answer").style.backgroundColor = "#FFCCCC";
	//	flag_error="error";
	//}
	//alert(flag_error);
	if (flag_error=="error")
	{
		return (false);
	}

	/*
	  //旧验证码删除 20080408 开始
	  if (isNaN(document.form1.validate_key.value) == true)
	  {	
		window.alert("请输入正确的验证码！");
		document.form1.validate_key.focus();
		return (false);
	  }
	  //旧验证码删除 20080408 结束
	 */

	document.form1.action="v6/v6_regsub.asp";
	document.form1.submitb.disabled=false;
}

